﻿using Jack.RemoteLog;
using JMS;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CheckIn
{
    public static class Extention
    {
        public static void RegisterService(this IServiceCollection services,bool isAspNet = false)
        {
            services.AddSingleton<ITimeProvider,BeijingTimeProvider>();

            if (Global.GatewayAddresses != null)
            {
                services.AddTransient(s => new RemoteClient(Global.GatewayAddresses));
            }

            services.AddLogging(builder =>
            {
                builder.AddConfiguration(Global.Configuration.GetSection("Logging"));
                builder.AddConsole();
                builder.UseJackRemoteLogger(Global.Configuration);
            });

            //身份验证
            if (isAspNet)
            {
                
            }
            else
            {
              
                services.AddJwtTokenAuthentication(Global.Configuration["JwtSecret"], new string[] { "Authorization" });
            }
        }
    }
}
